auto.waitFor()
var appRun = currentActivity()
var t=0

/**
 * 上滑
 */
 function swipe_my(){

    // random_time = getRndInteger(500,1500)
    
    // swipe(500, 1800, 500, 800, random(200,1500))

    swipe(500, random(1800,2000), 500, random(100,600), random(200,1500))

    // gesture(1000, [600, 1600], [500, 1000])

}
/**
 * 
 * 通过bounds 点击
 * @param {*} btn  按钮对象
 */
 function clickBtnByBoundsCenter(btn) {
    var position = btn.bounds();
    press(position.centerX(), position.centerY(),1);
    sleep(500);
}

function one() {

    while(textEndsWith("滑动开始").exists()) {
        swipe_my()
        toast("滑动开始")
        sleep(300)
    };

    while(textEndsWith("继续滑动").exists()) {
        swipe_my()
        toast("找到继续滑动")
        sleep(300)
    };

    for (let times = 0; times < 5 ; times++) {
        if(descEndsWith("+500").exists()){
            toast("+500")

            var btn = text("+500").findOne(1000)
            clickBtnByBoundsCenter(btn)
            sleep(3000)
            break;
        }else{
            toast('尝试寻找[+500]，第'+times+'次')
        }

        
    }
   
}

let flag=true
while(flag==true){
    one()
    toast("第"+t+"次完毕")
    t++;
    if(t>60){flag=false}
    sleep(500)
}



